package com.manopservice.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.manopservice.dao.CarBrandDAO;
import com.manopservice.model.CarBrand;

@Service("carBrandService")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class CarBrandServiceImpl implements CarBrandService {

	@Autowired
	private CarBrandDAO carBrandDAO;

	public CarBrandServiceImpl() {
	}

	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
	public void saveCarBrand(CarBrand carBrand) {
		carBrandDAO.save(carBrand);
	}
	
	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
	public void deleteCarBrand(int id) {
		carBrandDAO.delete(id);
		
	}

	public List<CarBrand> listCarBrands() {
		return carBrandDAO.findAll();
	}

	@Override
	public CarBrand findCarBrandById(int id) {		
		return carBrandDAO.findById(id);
	}

}
